package com.cqut.forum.entity;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * @author yangxun User entity
 */
@Entity
@Table(name = "user", catalog = "forum")
public class User implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer userId;
	private Role role;
	private String userName;
	private String userPassword;
	private String userEmail;
	private String userSex;
	private Date userBirthday;
	private String userSign;
	private String userPlace;
	private String userPhoto;
	private Boolean userState;
	private Date userTime;
	private Date userLastLoginTime;
	private String userQQ;
	private String userWork;
	private Integer userScore = 0;
	private Set<Messages> messageses = new HashSet<Messages>(0);
	private Set<Level> levels = new HashSet<Level>(0);
	private Set<Relation> relations = new HashSet<Relation>(0);
	private Set<UserNews> userNewses = new HashSet<UserNews>(0);
	private Set<UserLog> userLogs = new HashSet<UserLog>(0);
	private Set<GroupRelation> groupRelations = new HashSet<GroupRelation>(0);
	//private Set<ModuleInformation> moduleInformation = new HashSet<ModuleInformation>(0);
	// Constructors

	/** default constructor */
	public User() {
	}

	/** full constructor */
	public User(Role role, String userName, String userPassword,
			String userEmail, String userSex, Date userBirthday,String userQQ,
			String userSign, String userPlace, String userPhoto,String userWork,
			Boolean userState, Date userTime, Date userLastLoginTime,
			Integer userScore,Set<Messages> messageses,
			Set<Level> levels, Set<Relation> relations,
			Set<UserNews> userNewses, Set<UserLog> userLogs,
			Set<GroupRelation> groupRelations) {
		this.role = role;
		this.userName = userName;
		this.userPassword = userPassword;
		this.userEmail = userEmail;
		this.userSex = userSex;
		this.userBirthday = userBirthday;
		this.userSign = userSign;
		this.userPlace = userPlace;
		this.userPhoto = userPhoto;
		this.userState = userState;
		this.userTime = userTime;
		this.userLastLoginTime = userLastLoginTime;
		this.userScore = userScore;
		this.messageses = messageses;
		this.levels = levels;
		this.relations = relations;
		this.userNewses = userNewses;
		this.userLogs = userLogs;
		this.groupRelations = groupRelations;
		
		this.userQQ = userQQ;
		this.userWork = userWork;
		//this.moduleInformation = moduleInformation;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "user_id", unique = true, nullable = false)
	public Integer getUserId() {
		return this.userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "role_id")
	public Role getRole() {
		return this.role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	@Column(name = "user_name", length = 20)
	public String getUserName() {
		return this.userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	@Column(name = "user_password", length = 16)
	public String getUserPassword() {
		return this.userPassword;
	}

	public void setUserPassword(String userPassword) {
		this.userPassword = userPassword;
	}

	@Column(name = "user_email", length = 50)
	public String getUserEmail() {
		return this.userEmail;
	}

	public void setUserEmail(String userEmail) {
		this.userEmail = userEmail;
	}

	@Column(name = "user_sex", length = 2)
	public String getUserSex() {
		return this.userSex;
	}

	public void setUserSex(String userSex) {
		this.userSex = userSex;
	}

	@Column(name = "user_birthday", length = 10)
	public Date getUserBirthday() {
		return this.userBirthday;
	}

	public void setUserBirthday(Date userBirthday) {
		this.userBirthday = userBirthday;
	}

	@Column(name = "user_sign", length = 100)
	public String getUserSign() {
		return this.userSign;
	}

	public void setUserSign(String userSign) {
		this.userSign = userSign;
	}

	@Column(name = "user_place", length = 50)
	public String getUserPlace() {
		return this.userPlace;
	}

	public void setUserPlace(String userPlace) {
		this.userPlace = userPlace;
	}

	@Column(name = "user_photo", length = 100)
	public String getUserPhoto() {
		return this.userPhoto;
	}

	public void setUserPhoto(String userPhoto) {
		this.userPhoto = userPhoto;
	}

	@Column(name = "user_state")
	public Boolean getUserState() {
		return this.userState;
	}

	public void setUserState(Boolean userState) {
		this.userState = userState;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
	public Set<Messages> getMessageses() {
		return this.messageses;
	}

	public void setMessageses(Set<Messages> messageses) {
		this.messageses = messageses;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
	public Set<Level> getLevels() {
		return this.levels;
	}

	public void setLevels(Set<Level> levels) {
		this.levels = levels;
	}
	@Column(name = "user_qq", length = 16)
	public String getUserQQ() {
		return userQQ;
	}

	public void setUserQQ(String userQQ) {
		this.userQQ = userQQ;
	}
	@Column(name = "user_work", length = 100)
	public String getUserWork() {
		return userWork;
	}

	public void setUserWork(String userWork) {
		this.userWork = userWork;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
	public Set<Relation> getRelations() {
		return this.relations;
	}

	public void setRelations(Set<Relation> relations) {
		this.relations = relations;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
	public Set<UserNews> getUserNewses() {
		return this.userNewses;
	}

	public void setUserNewses(Set<UserNews> userNewses) {
		this.userNewses = userNewses;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
	public Set<UserLog> getUserLogs() {
		return this.userLogs;
	}

	public void setUserLogs(Set<UserLog> userLogs) {
		this.userLogs = userLogs;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
	public Set<GroupRelation> getGroupRelations() {
		return this.groupRelations;
	}

	public void setGroupRelations(Set<GroupRelation> groupRelations) {
		this.groupRelations = groupRelations;
	}
	
	/*@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
	public Set<ModuleInformation> getModuleInformation() {
		return moduleInformation;
	}

	public void setModuleInformation(Set<ModuleInformation> moduleInformation) {
		this.moduleInformation = moduleInformation;
	}*/

	@Column(name = "user_time")
	public Date getUserTime() {
		return userTime;
	}

	public void setUserTime(Date userTime) {
		this.userTime = userTime;
	}
	@Column(name = "user_last_login_time")
	public Date getUserLastLoginTime() {
		return userLastLoginTime;
	}

	public void setUserLastLoginTime(Date userLastLoginTime) {
		this.userLastLoginTime = userLastLoginTime;
	}

	@Column(name = "user_score")
	public Integer getUserScore() {
		return userScore;
	}
	public void setUserScore(Integer userScore) {
		this.userScore = userScore;
	}
}